﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.ApplicationBlocks.Data;
using System.Configuration;
namespace ModuleDuoc.DM
{
    public partial class DM_NHACC : ModuleDuoc.Base.frmAddBase
    {
        public DM_NHACC()
        {
            InitializeComponent();
        }
        public override void btnSave_Click(object sender, EventArgs e)
        {
            base.btnSave_Click(sender, e);
            string sql = "insert into zD_NHACUNGCAP(MANCC,TENNCC) values('" + this.txtMaNCCs.Text.Trim() + "',N'" + this.txtTenNhaCCs.Text.Trim() + "')";
            SqlHelper.ExecuteNonQuery(ConfigurationManager.AppSettings["Main.ConnectionString"], CommandType.Text, sql);
            MessageBox.Show("Thêm mới thành công!", "Thông báo");
            this.Close();
        }

        private void pnlData_Paint(object sender, PaintEventArgs e)
        {

        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DM_NHACC_Load(object sender, EventArgs e)
        {
            try
            {
                string sql = "select MANCC,TENNCC from zD_NHACUNGCAP";
                dgvData.DataSource = SqlHelper.ExecuteDataset(ConfigurationManager.AppSettings["Main.ConnectionString"], CommandType.Text, sql).Tables[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show("Có lỗi khi hiển thị dữ liệu : " + ex.Message, "Thông báo");
            }
        }
    }
}
